﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using IdeaBlade.EntityModel;
using SWTORLogDb.Entities.SWTOR;
using SWTORLogDb.Entities.SWTOR.CombatLogs;

namespace SWTORLogDb.Contexts
{
    public class SWTORLogDb : DbContext
    {
        public DbSet<Player> Players { get; set; }
        public DbSet<Character> Characters { get; set; }
        public DbSet<Guild> Guilds { get; set; }
        public DbSet<Server> Servers { get; set; }
        public DbSet<CharacterCrewSkill> CharacterCrewSkills { get; set; }
        public DbSet<Encounter> Encounters { get; set; }
        public DbSet<Operation> Operations { get; set; }
        public DbSet<OperationBoss> OperationBosses { get; set; }
        public DbSet<OperationZone> OperationZones { get; set; }
        public DbSet<CombatLogEntry> CombatLogEntries { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();

            modelBuilder.Ignore<EntityAspect>();
        }

        public SWTORLogDb()
        {
            if (HttpContext.Current == null) Database.SetInitializer<SWTORLogDb>(null);
        }
    }
}
